<template>
  <view>
    <view>
      <view class="img_wrap">
        <image :src="activity.imgUrl" mode="aspectFill" lazy-load />
      </view>
    </view>
    <view class="cu-card">
      <view class="cu-item bg-white shadow">
        <view class="segn_wrap">
          <uni-segmented-control
            :current="current"
            :values="items.map(v=>v.title)"
            @clickItem="handleClick"
            style-type="text"
            active-color="#feb2b2"
          ></uni-segmented-control>
        </view>
      </view>
    </view>

    <!-- 组件显示 -->
    <view class="segn_content">
      <view v-if="current === 0">
        <!-- <course-desc :coursesList="coursesList" @handLF="liekandfollow"></course-desc> -->
        <act-desc :myId="id"></act-desc>
      </view>
      <view v-if="current === 1">
        <act-works :myId="id"></act-works>
      </view>
      <view v-if="current === 2">
        <act-comments :myId="id"></act-comments>
      </view>
    </view>
  </view>
</template>

<script>
import actWorks from "./activaties-works/index";
import actComments from "./activities-comments/index";
import actDesc from "./activitesDetail-desc/index";
import { uniSegmentedControl } from "@dcloudio/uni-ui";
export default {
  components: {
    actComments,
    actDesc,
    actWorks,
    uniSegmentedControl
  },
  data() {
    return {
      activity: [],
      coursesList: {},
      id: 0,
      imgUrl: "",
      type: "",
      current: 0,
      items: [
        {
          title: "简介"
        },
        {
          title: "活动作品"
        },
        {
          title: "评论"
        }
      ]
    };
  },
  onLoad(option) {
    console.log("activitiesDetail");
    console.log(option);
    this.id = option.id;
    //this.id = 13;
    this.getAct();
  },
  methods: {
    getAct() {
      this.request({
        url:
          this.apiServer +
          "/activities/findActivitiesByIdAndUId?id=" +
          this.id +
          "&uId=" +
          uni.getStorageSync("user").id
      }).then(res => {
        console.log(res);
        this.activity = res.data;
      });
    },
    handleClick(e) {
      if (this.current != e.currentIndex) {
        this.current = e.currentIndex;
      }
    }
  }
};
</script>

<style>
.work-content {
  word-break: break-all;
  white-space: pre-wrap;
}
</style>
